import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {

    public static int dis(int i, int j, int n) {
        return Math.min(Math.abs(i - j), n - Math.abs(i - j));
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        
        int n = in.nextInt();
        int[] arrs = new int[n];
        for (int i = 0; i < n; i++) {
            arrs[i] = in.nextInt();
        }

        int ret = Integer.MIN_VALUE;

        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                ret = Math.max(ret, (arrs[i] + arrs[j]) * dis(i, j, n));
            }
        }

        System.out.println(ret);
    }
}